//
//  UTEDeviceLanguage.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/8/5.
//

import Foundation

@objc enum SWUTEDeviceLanguage: Int {
    case UTEDeviceLanguageChinese    = 1      //中文
    case UTEDeviceLanguageEnglish    = 2       //英语
    case UTEDeviceLanguageKorean     = 3        //韩语
    case UTEDeviceLanguageJapanese   = 4        //日语
    case UTEDeviceLanguageGerman     = 5        //德语
    case UTEDeviceLanguageSpanish    = 6        //西班牙语
    case UTEDeviceLanguageFrench     = 7        //法语
    case UTEDeviceLanguageItalian    = 8       //意大利语
    case UTEDeviceLanguagePortuguese  = 9        //葡萄牙语
    case UTEDeviceLanguageArabic     = 10        //阿拉伯语
    case UTEDeviceLanguageIndia      = 11        //印度语
    case UTEDeviceLanguageHindi      = 12        //印地语
    case UTEDeviceLanguagePolish     = 13        //波兰语
    case UTEDeviceLanguageRussian    = 14        //俄语
    case UTEDeviceLanguageDutch      = 15        //荷兰语
    case UTEDeviceLanguageTurkey     = 16        //土耳其
    case UTEDeviceLanguageBengal     = 17        //孟加拉语
    case UTEDeviceLanguageUrdu       = 18        //乌尔都语
    case UTEDeviceLanguageIndonesia  = 19        //印度尼西亚语
    case UTEDeviceLanguagePunjabi    = 20        //旁遮普语
    case UTEDeviceLanguageThai       = 21        //泰语
    case UTEDeviceLanguageCzech      = 22        //捷克语
    case UTEDeviceLanguageChinese_t  = 23        //中文繁体
    case UTEDeviceLanguageHebrew     = 24        //希伯来语
    case UTEDeviceLanguageSlovakia   = 25        //斯洛伐克
    case UTEDeviceLanguageHungary    = 26        //匈牙利
    case UTEDeviceLanguageRomania    = 27        //罗马尼亚
    case UTEDeviceLanguageBelarus    = 28        //白俄罗斯
    case UTEDeviceLanguageEesti      = 29        //爱沙尼亚
    case UTEDeviceLanguageAlgeria    = 30        //阿尔及利亚
    case UTEDeviceLanguageAmharic    = 31        //阿姆哈拉
    case UTEDeviceLanguageAzerbaijan = 32        //阿塞拜疆
    case UTEDeviceLanguageIreland    = 33        //爱尔兰
    case UTEDeviceLanguageOccitan    = 34        //欧西坦语(奥克语)
    case UTEDeviceLanguageOriya      = 35        //奥里亚语
    case UTEDeviceLanguageOromoo     = 36        //奥罗莫语
    case UTEDeviceLanguageEuskera    = 37        //巴斯克语
    case UTEDeviceLanguageBulgaria   = 38        //保加利亚
    case UTEDeviceLanguageBosnia     = 39        //波斯尼亚
    case UTEDeviceLanguagePersian    = 40        //波斯语
    case UTEDeviceLanguagePhilippines   = 41     //菲律宾
    case UTEDeviceLanguageKhmer      = 42        //高棉语
    case UTEDeviceLanguageGujarat    = 43        //古吉拉特语
    case UTEDeviceLanguageKazakhstan = 44        //哈萨克斯坦
    case UTEDeviceLanguageAyisyen    = 45        //海地克里奥语(海地语/克里奥耳语)
    case UTEDeviceLanguageHausa      = 46        //豪萨语
    case UTEDeviceLanguageMontenegrin = 47       //黑山语
    case UTEDeviceLanguageCatalunya  = 48        //加泰罗尼亚语
    case UTEDeviceLanguageKannada    = 49        //卡纳达语
    case UTEDeviceLanguageXhosa      = 50        //科萨语
    case UTEDeviceLanguageHrvatska   = 51        //克罗地亚语
    case UTEDeviceLanguageQuechua    = 52        //克丘亚语
    case UTEDeviceLanguageKurdish    = 53        //库尔德语
    case UTEDeviceLanguageLatin      = 54        //拉丁语
    case UTEDeviceLanguageTzebuergesch = 55      //卢森堡语
    case UTEDeviceLanguageKinyarwanda  = 56      //卢旺达语
    case UTEDeviceLanguageDenmark    = 57        //丹麦语
    case UTEDeviceLanguageRome       = 58        //罗马语
    case UTEDeviceLanguageRomansh    = 59        //罗曼什语
    case UTEDeviceLanguageMalagasy   = 60        //马达加斯加
    case UTEDeviceLanguageMarathi    = 61        //马拉地语(मराठी)
    case UTEDeviceLanguageMarathi_1  = 62        //马拉提语
    case UTEDeviceLanguageMalayalam  = 63        //马拉雅拉姆语
    case UTEDeviceLanguageMalaysia   = 64        //马来西亚
    case UTEDeviceLanguageMacedonia  = 65        //马其顿语
    case UTEDeviceLanguageMaithili   = 66        //迈蒂利语
    case UTEDeviceLanguageGaelg      = 67        //曼克斯(曼岛语)
    case UTEDeviceLanguageMyanmar    = 68        //缅甸语
    case UTEDeviceLanguageNaples     = 69        //那不勒斯语
    case UTEDeviceLanguageNepal      = 70        //尼泊尔语
    case UTEDeviceLanguageNorge      = 71        //挪威语
    case UTEDeviceLanguagePashto     = 72        //普什图语
    case UTEDeviceLanguageChichewa   = 73        //齐切瓦语
    case UTEDeviceLanguageSverige    = 74        //瑞典
    case UTEDeviceLanguageSerbia     = 75        //赛尔维亚语
    case UTEDeviceLanguageSinhalese  = 76        //僧伽罗语
    case UTEDeviceLanguageSlovenski  = 77        //斯洛文尼亚语
    case UTEDeviceLanguageKiswahili  = 78        //斯瓦希里语
    case UTEDeviceLanguageCebu       = 79        //宿务语
    case UTEDeviceLanguageSomali     = 80        //索马里语
    case UTEDeviceLanguageSamoan     = 81        //萨摩亚语
    case UTEDeviceLanguageTagalog    = 82        //他加禄语
    case UTEDeviceLanguageTajik      = 83        //塔吉克语
    case UTEDeviceLanguageTelangana  = 84        //泰卢固语
    case UTEDeviceLanguageTamil      = 85        //泰米尔语
    case UTEDeviceLanguageTigray     = 86        //提格利尼亚语
    case UTEDeviceLanguageTurkmen    = 87        //土库曼语
    case UTEDeviceLanguageUkraine    = 88        //乌克兰语
    case UTEDeviceLanguageUzbekistan = 89        //乌兹别克语
    case UTEDeviceLanguageGreek      = 90        //希腊语
    case UTEDeviceLanguageSindhi     = 91        //信德语
    case UTEDeviceLanguageShona      = 92        //修纳语
    case UTEDeviceLanguageSyriac     = 93        //叙利亚语
    case UTEDeviceLanguageIgbo       = 94        //伊博语
    case UTEDeviceLanguageIlokano    = 95        //伊洛卡诺语
    case UTEDeviceLanguagePending2   = 96        //预留、待定
    case UTEDeviceLanguageYoruba     = 97        //约鲁巴语
    case UTEDeviceLanguageFinnish    = 98        //芬兰语
    case UTEDeviceLanguageVietnam    = 99        //越南语
    case UTEDeviceLanguageIsiZulu    = 100       //祖鲁语
    case UTEDeviceLanguageMongolia   = 101       //蒙古语
    case UTEDeviceLanguageSpanisha   = 102       //西班牙（拉丁美洲）
    case UTEDeviceLanguageOther      = -2  //other
    case UTEDeviceLanguageNone       = -1
    
    var description: String {
        switch self {
        case .UTEDeviceLanguageChinese: return "中文"
        case .UTEDeviceLanguageEnglish: return "English"
        case .UTEDeviceLanguageKorean: return "한국어"
        case .UTEDeviceLanguageJapanese: return "日本語"
        case .UTEDeviceLanguageGerman: return "Deutsch"
        case .UTEDeviceLanguageSpanish: return "Español"
        case .UTEDeviceLanguageFrench: return "Français"
        case .UTEDeviceLanguageItalian: return "Italiano"
        case .UTEDeviceLanguagePortuguese: return "Português"
        case .UTEDeviceLanguageArabic: return "العربية"
        case .UTEDeviceLanguageIndia: return "भारतीय"
        case .UTEDeviceLanguageHindi: return "हिन्दी"
        case .UTEDeviceLanguagePolish: return "Polski"
        case .UTEDeviceLanguageRussian: return "Русский"
        case .UTEDeviceLanguageDutch: return "Nederlands"
        case .UTEDeviceLanguageTurkey: return "Türkçe"
        case .UTEDeviceLanguageBengal: return "বাংলা"
        case .UTEDeviceLanguageUrdu: return "اردو"
        case .UTEDeviceLanguageIndonesia: return "Bahasa Indonesia"
        case .UTEDeviceLanguagePunjabi: return "ਪੰਜਾਬੀ"
        case .UTEDeviceLanguageThai: return "ไทย"
        case .UTEDeviceLanguageCzech: return "Čeština"
        case .UTEDeviceLanguageChinese_t: return "繁體中文"
        case .UTEDeviceLanguageHebrew: return "עברית"
        case .UTEDeviceLanguageSlovakia: return "Slovenčina"
        case .UTEDeviceLanguageHungary: return "Magyar"
        case .UTEDeviceLanguageRomania: return "Română"
        case .UTEDeviceLanguageBelarus: return "Беларуская"
        case .UTEDeviceLanguageEesti: return "Eesti"
        case .UTEDeviceLanguageAlgeria: return "الجزائرية"
        case .UTEDeviceLanguageAmharic: return "አማርኛ"
        case .UTEDeviceLanguageAzerbaijan: return "Azərbaycan"
        case .UTEDeviceLanguageIreland: return "Gaeilge"
        case .UTEDeviceLanguageOccitan: return "Occitan"
        case .UTEDeviceLanguageOriya: return "ଓଡ଼ିିଆ"
        case .UTEDeviceLanguageOromoo: return "Afaan Oromoo"
        case .UTEDeviceLanguageEuskera: return "Euskara"
        case .UTEDeviceLanguageBulgaria: return "Български"
        case .UTEDeviceLanguageBosnia: return "Bosanski"
        case .UTEDeviceLanguagePersian: return "فارسی"
        case .UTEDeviceLanguagePhilippines: return "Filipino"
        case .UTEDeviceLanguageKhmer: return "ភាាសាាខ្្មែរ"
        case .UTEDeviceLanguageGujarat: return "ગુજરાતી"
        case .UTEDeviceLanguageKazakhstan: return "Қазақ"
        case .UTEDeviceLanguageAyisyen: return "Kreyòl ayisyen"
        case .UTEDeviceLanguageHausa: return "Hausa"
        case .UTEDeviceLanguageMontenegrin: return "Crnogorski"
        case .UTEDeviceLanguageCatalunya: return "Català"
        case .UTEDeviceLanguageKannada: return "ಕನ್ನಡ"
        case .UTEDeviceLanguageXhosa: return "isiXhosa"
        case .UTEDeviceLanguageHrvatska: return "Hrvatski"
        case .UTEDeviceLanguageQuechua: return "Runasimi"
        case .UTEDeviceLanguageKurdish: return "Kurdî"
        case .UTEDeviceLanguageLatin: return "Latina"
        case .UTEDeviceLanguageTzebuergesch: return "Lëtzebuergesch"
        case .UTEDeviceLanguageKinyarwanda: return "Kinyarwanda"
        case .UTEDeviceLanguageDenmark: return "Dansk"
        case .UTEDeviceLanguageRome: return "Romagnolo"
        case .UTEDeviceLanguageRomansh: return "Rumantsch"
        case .UTEDeviceLanguageMalagasy: return "Malagasy"
        case .UTEDeviceLanguageMarathi: return "मरााठी"
        case .UTEDeviceLanguageMarathi_1: return "मराठी"
        case .UTEDeviceLanguageMalayalam: return "മലയാാളം"
        case .UTEDeviceLanguageMalaysia: return "Bahasa Melayu"
        case .UTEDeviceLanguageMacedonia: return "Македонски"
        case .UTEDeviceLanguageMaithili: return "मैथिली"
        case .UTEDeviceLanguageGaelg: return "Gaelg"
        case .UTEDeviceLanguageMyanmar: return "မမြန်န်မာာဘာာသာ"
        case .UTEDeviceLanguageNaples: return "Nnapulitano"
        case .UTEDeviceLanguageNepal: return "नेपाली"
        case .UTEDeviceLanguageNorge: return "Norsk"
        case .UTEDeviceLanguagePashto: return "پښتو"
        case .UTEDeviceLanguageChichewa: return "Chichewa"
        case .UTEDeviceLanguageSverige: return "Svenska"
        case .UTEDeviceLanguageSerbia: return "Српски"
        case .UTEDeviceLanguageSinhalese: return "සිංහල"
        case .UTEDeviceLanguageSlovenski: return "Slovenščina"
        case .UTEDeviceLanguageKiswahili: return "Kiswahili"
        case .UTEDeviceLanguageCebu: return "Binisaya"
        case .UTEDeviceLanguageSomali: return "Soomaali"
        case .UTEDeviceLanguageSamoan: return "Gagana Samoa"
        case .UTEDeviceLanguageTagalog: return "Tagalog"
        case .UTEDeviceLanguageTajik: return "Тоҷикӣ"
        case .UTEDeviceLanguageTelangana: return "తెలుగు"
        case .UTEDeviceLanguageTamil: return "தமிழ்"
        case .UTEDeviceLanguageTigray: return "ትግርኛ"
        case .UTEDeviceLanguageTurkmen: return "Türkmençe"
        case .UTEDeviceLanguageUkraine: return "Українська"
        case .UTEDeviceLanguageUzbekistan: return "Oʻzbekcha"
        case .UTEDeviceLanguageGreek: return "Ελληνικά"
        case .UTEDeviceLanguageSindhi: return "سنڌي"
        case .UTEDeviceLanguageShona: return "chiShona"
        case .UTEDeviceLanguageSyriac: return "ܠܫܢܐ ܣܘܪܝܝܐ"
        case .UTEDeviceLanguageIgbo: return "Igbo"
        case .UTEDeviceLanguageIlokano: return "Ilokano"
        case .UTEDeviceLanguagePending2: return "Reserved"
        case .UTEDeviceLanguageYoruba: return "Yorùbá"
        case .UTEDeviceLanguageFinnish: return "Suomi"
        case .UTEDeviceLanguageVietnam: return "Tiếng Việt"
        case .UTEDeviceLanguageIsiZulu: return "isiZulu"
        case .UTEDeviceLanguageMongolia: return "Монгол"
        case .UTEDeviceLanguageSpanisha: return "Español (Latinoamérica)"
        case .UTEDeviceLanguageOther: return "Other"
        case .UTEDeviceLanguageNone: return "None"
        }
    }
}


func mapLanguageIndicesToDescriptions(indices: [NSNumber]) -> [String] {
    return indices.compactMap { number in
        SWUTEDeviceLanguage(rawValue: number.intValue)?.description ?? "未知语言"
    }
}


func mapLanguageIndicesToDescription(indice: Int) -> String {
    return SWUTEDeviceLanguage(rawValue: indice)?.description ?? "未知语言"
}

extension SWUTEDeviceLanguage {
    static func fromDescription(_ description: String) -> SWUTEDeviceLanguage? {
        switch description {
        case "中文": return .UTEDeviceLanguageChinese
        case "English": return .UTEDeviceLanguageEnglish
        case "한국어": return .UTEDeviceLanguageKorean
        case "日本語": return .UTEDeviceLanguageJapanese
        case "Deutsch": return .UTEDeviceLanguageGerman
        case "Español": return .UTEDeviceLanguageSpanish
        case "Français": return .UTEDeviceLanguageFrench
        case "Italiano": return .UTEDeviceLanguageItalian
        case "Português": return .UTEDeviceLanguagePortuguese
        case "العربية": return .UTEDeviceLanguageArabic
        case "भारतीय": return .UTEDeviceLanguageIndia
        case "हिन्दी": return .UTEDeviceLanguageHindi
        case "Polski": return .UTEDeviceLanguagePolish
        case "Русский": return .UTEDeviceLanguageRussian
        case "Nederlands": return .UTEDeviceLanguageDutch
        case "Türkçe": return .UTEDeviceLanguageTurkey
        case "বাংলা": return .UTEDeviceLanguageBengal
        case "اردو": return .UTEDeviceLanguageUrdu
        case "Bahasa Indonesia": return .UTEDeviceLanguageIndonesia
        case "ਪੰਜਾਬੀ": return .UTEDeviceLanguagePunjabi
        case "ไทย": return .UTEDeviceLanguageThai
        case "Čeština": return .UTEDeviceLanguageCzech
        case "繁體中文": return .UTEDeviceLanguageChinese_t
        case "עברית": return .UTEDeviceLanguageHebrew
        case "Slovenčina": return .UTEDeviceLanguageSlovakia
        case "Magyar": return .UTEDeviceLanguageHungary
        case "Română": return .UTEDeviceLanguageRomania
        case "Беларуская": return .UTEDeviceLanguageBelarus
        case "Eesti": return .UTEDeviceLanguageEesti
        case "الجزائرية": return .UTEDeviceLanguageAlgeria
        case "አማርኛ": return .UTEDeviceLanguageAmharic
        case "Azərbaycan": return .UTEDeviceLanguageAzerbaijan
        case "Gaeilge": return .UTEDeviceLanguageIreland
        case "Occitan": return .UTEDeviceLanguageOccitan
        case "ଓଡ଼ିିଆ": return .UTEDeviceLanguageOriya
        case "Afaan Oromoo": return .UTEDeviceLanguageOromoo
        case "Euskara": return .UTEDeviceLanguageEuskera
        case "Български": return .UTEDeviceLanguageBulgaria
        case "Bosanski": return .UTEDeviceLanguageBosnia
        case "فارسی": return .UTEDeviceLanguagePersian
        case "Filipino": return .UTEDeviceLanguagePhilippines
        case "ភាាាសាាខ្្មែរ": return .UTEDeviceLanguageKhmer
        case "ગુજરાાતી": return .UTEDeviceLanguageGujarat
        case "Қазақ": return .UTEDeviceLanguageKazakhstan
        case "Kreyòl ayisyen": return .UTEDeviceLanguageAyisyen
        case "Hausa": return .UTEDeviceLanguageHausa
        case "Crnogorski": return .UTEDeviceLanguageMontenegrin
        case "Català": return .UTEDeviceLanguageCatalunya
        case "ಕನ್ನಡ": return .UTEDeviceLanguageKannada
        case "isiXhosa": return .UTEDeviceLanguageXhosa
        case "Hrvatski": return .UTEDeviceLanguageHrvatska
        case "Runasimi": return .UTEDeviceLanguageQuechua
        case "Kurdî": return .UTEDeviceLanguageKurdish
        case "Latina": return .UTEDeviceLanguageLatin
        case "Lëtzebuergesch": return .UTEDeviceLanguageTzebuergesch
        case "Kinyarwanda": return .UTEDeviceLanguageKinyarwanda
        case "Dansk": return .UTEDeviceLanguageDenmark
        case "Romagnolo": return .UTEDeviceLanguageRome
        case "Rumantsch": return .UTEDeviceLanguageRomansh
        case "Malagasy": return .UTEDeviceLanguageMalagasy
        case "मरााठी": return .UTEDeviceLanguageMarathi
        case "मराठी": return .UTEDeviceLanguageMarathi_1
        case "മലയാാളം": return .UTEDeviceLanguageMalayalam
        case "Bahasa Melayu": return .UTEDeviceLanguageMalaysia
        case "Македонски": return .UTEDeviceLanguageMacedonia
        case "मैथिली": return .UTEDeviceLanguageMaithili
        case "Gaelg": return .UTEDeviceLanguageGaelg
        case "မမြန်န်မာာဘာာသာ": return .UTEDeviceLanguageMyanmar
        case "Nnapulitano": return .UTEDeviceLanguageNaples
        case "नेपाली": return .UTEDeviceLanguageNepal
        case "Norsk": return .UTEDeviceLanguageNorge
        case "پښتو": return .UTEDeviceLanguagePashto
        case "Chichewa": return .UTEDeviceLanguageChichewa
        case "Svenska": return .UTEDeviceLanguageSverige
        case "Српски": return .UTEDeviceLanguageSerbia
        case "සිංහල": return .UTEDeviceLanguageSinhalese
        case "Slovenščina": return .UTEDeviceLanguageSlovenski
        case "Kiswahili": return .UTEDeviceLanguageKiswahili
        case "Binisaya": return .UTEDeviceLanguageCebu
        case "Soomaali": return .UTEDeviceLanguageSomali
        case "Gagana Samoa": return .UTEDeviceLanguageSamoan
        case "Tagalog": return .UTEDeviceLanguageTagalog
        case "Тоҷикӣ": return .UTEDeviceLanguageTajik
        case "తెలుగు": return .UTEDeviceLanguageTelangana
        case "தமிழ்": return .UTEDeviceLanguageTamil
        case "ትግርኛ": return .UTEDeviceLanguageTigray
        case "Türkmençe": return .UTEDeviceLanguageTurkmen
        case "Українська": return .UTEDeviceLanguageUkraine
        case "Oʻzbekcha": return .UTEDeviceLanguageUzbekistan
        case "Ελληνικά": return .UTEDeviceLanguageGreek
        case "سنڌي": return .UTEDeviceLanguageSindhi
        case "chiShona": return .UTEDeviceLanguageShona
        case "ܠܫܢܐ ܣܘܪܝܝܐ": return .UTEDeviceLanguageSyriac
        case "Igbo": return .UTEDeviceLanguageIgbo
        case "Ilokano": return .UTEDeviceLanguageIlokano
        case "Reserved": return .UTEDeviceLanguagePending2
        case "Yorùbá": return .UTEDeviceLanguageYoruba
        case "Suomi": return .UTEDeviceLanguageFinnish
        case "Tiếng Việt": return .UTEDeviceLanguageVietnam
        case "isiZulu": return .UTEDeviceLanguageIsiZulu
        case "Монгол": return .UTEDeviceLanguageMongolia
        case "Español (Latinoamérica)": return .UTEDeviceLanguageSpanisha
        case "Other": return .UTEDeviceLanguageOther
        case "None": return .UTEDeviceLanguageNone
        default: return nil
        }
    }
}
